//
//  TradeHeaderView.m
//  BTCoin
//
//  Created by Robin on 29/03/2018.
//  Copyright © 2018 Robin. All rights reserved.
//

#import "TradeHeaderView.h"
#import "UIImage+Extension.h"

@interface TradeHeaderView ()
@property (nonatomic,strong) UIButton * tradeTypeBtn;
@property (nonatomic,strong) UIButton * BTCBtn;
@end

@implementation TradeHeaderView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        
        _tradeTypeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_tradeTypeBtn setTitle:@"LTC/USDT" forState:UIControlStateNormal];
        [_tradeTypeBtn addTarget:self action:@selector(menuAction:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:_tradeTypeBtn];
        [_tradeTypeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.equalTo(self);
        }];
        
        UIImageView * arrowDown = [[UIImageView alloc] init];
        arrowDown.image = [UIImage imageNamed:@"trade_type_arrow_down"];
        [self addSubview:arrowDown];
        [arrowDown mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self);
            make.leading.equalTo(_tradeTypeBtn.mas_trailing).offset(5);
            make.width.mas_equalTo(16);
            make.height.mas_equalTo(8);
        }];
    }
    
    return self;
}

- (void)menuAction:(UIButton*)sender {
    if (_block) {
        self.block();
    }
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
